<html>
<head><meta charset="utf-8"><title>obtaining backtraces · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html">obtaining backtraces</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="187350857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187350857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187350857">(Feb 04 2020 at 11:36)</a>:</h4>
<p>Hi! rust-analyzer crashes very often for me. I've already installed a debug build, but don't know how to obtain a backtrace. I'm using ra from vscode, and running that from a terminal, even with <code>-w</code>, produces no output when the extension host crashes. Also the ra logs under <code>.config/Code/logs/*/exthost1/output_logging_*/*-Rust*</code> are mostly empty (no backtraces). I'm using arch linux. Help?</p>



<a name="187351543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187351543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187351543">(Feb 04 2020 at 11:50)</a>:</h4>
<p>How did you install the debug build? <code>cargo xtask install</code>?</p>



<a name="187351588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187351588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187351588">(Feb 04 2020 at 11:51)</a>:</h4>
<p>Did you set <code>RUST_BACKTRACE=1</code>?</p>



<a name="187351977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187351977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187351977">(Feb 04 2020 at 11:58)</a>:</h4>
<p>I usually build the server with <a href="https://github.com/rust-analyzer/rust-analyzer/blob/c1a06499fa5f9a40750cbfc30a7d399228a5fab0/Cargo.toml#L7" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/c1a06499fa5f9a40750cbfc30a7d399228a5fab0/Cargo.toml#L7"><code>debug = 2</code></a> via <code>cargo build</code> and then open an extension host that uses the built language server in VSCode debugger. You can refer to <a href="https://www.youtube.com/watch?v=O5EC81IUgsg&amp;feature=youtu.be" target="_blank" title="https://www.youtube.com/watch?v=O5EC81IUgsg&amp;feature=youtu.be">this video</a> where I recorded debugging process of a certain bug.</p>
<div class="youtube-video message_inline_image"><a data-id="O5EC81IUgsg" href="https://www.youtube.com/watch?v=O5EC81IUgsg&amp;feature=youtu.be" target="_blank" title="https://www.youtube.com/watch?v=O5EC81IUgsg&amp;feature=youtu.be"><img src="https://i.ytimg.com/vi/O5EC81IUgsg/default.jpg"></a></div>



<a name="187352019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187352019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187352019">(Feb 04 2020 at 12:00)</a>:</h4>
<p>Also very important, make sure to run <code>echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope</code> to enable <code>ptrace</code> of non-child processes</p>



<a name="187352269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187352269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187352269">(Feb 04 2020 at 12:04)</a>:</h4>
<p>We should refresh <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/debugging.md" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/debugging.md">debugging.md</a> file, though the only thing that changed there is the name of debug configs.</p>



<a name="187353415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187353415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187353415">(Feb 04 2020 at 12:19)</a>:</h4>
<p>mostly unrelated, but there's also a <code>ra_prof::print_backtrace</code> function which just dumps current backtrace to stderr.</p>



<a name="187367826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187367826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187367826">(Feb 04 2020 at 15:27)</a>:</h4>
<p>Yes, I installed via <code>cargo xtask install</code>. I set <code>RUST_BACKTRACE=full</code>, but I don't get any output whatsoever</p>



<a name="187367947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187367947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187367947">(Feb 04 2020 at 15:28)</a>:</h4>
<p>I'm not running ra in a debugger, do I have to do that?</p>



<a name="187368535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187368535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187368535">(Feb 04 2020 at 15:35)</a>:</h4>
<p><span class="user-mention" data-user-id="198047">@jplatte</span> if you want a backtrace only, you need to switch debug symbols on <a href="https://github.com/rust-analyzer/rust-analyzer/blob/c1a06499fa5f9a40750cbfc30a7d399228a5fab0/Cargo.toml#L7" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/c1a06499fa5f9a40750cbfc30a7d399228a5fab0/Cargo.toml#L7">here</a> set <code>debug = 2</code>. <span class="user-mention" data-user-id="133169">@matklad</span> I am I correct, that <code>cargo xtask install</code> does the debug build?</p>



<a name="187368554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187368554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187368554">(Feb 04 2020 at 15:35)</a>:</h4>
<p>I did that</p>



<a name="187368587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187368587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187368587">(Feb 04 2020 at 15:35)</a>:</h4>
<p>Oh wait, I did for the release profile</p>



<a name="187368588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187368588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187368588">(Feb 04 2020 at 15:36)</a>:</h4>
<p>So, what do you see in vscode Output tab <code>Rust Analyzer Language Server</code>?</p>



<a name="187368814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187368814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187368814">(Feb 04 2020 at 15:38)</a>:</h4>
<p>that output tab disappears once the extension host crashes</p>



<a name="187369209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369209">(Feb 04 2020 at 15:42)</a>:</h4>
<p>And the log files on disk for that are empty:</p>
<div class="codehilite"><pre><span></span>-rw-r--r-- 1 jplatte jplatte 0  4. Feb 16:37 &#39;.config/Code/logs/20200204T163721/exthost1/output_logging_20200204T163725/1-Rust Analyzer Language Server Trace.log&#39;
-rw-r--r-- 1 jplatte jplatte 0  4. Feb 16:38 &#39;.config/Code/logs/20200204T163721/exthost1/output_logging_20200204T163837/1-Rust Analyzer Language Server Trace.log&#39;
-rw-r--r-- 1 jplatte jplatte 0  4. Feb 16:38 &#39;.config/Code/logs/20200204T163721/exthost1/output_logging_20200204T163847/1-Rust Analyzer Language Server Trace.log&#39;
</pre></div>



<a name="187369371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369371">(Feb 04 2020 at 15:44)</a>:</h4>
<p>Hmm, are you sure this is the language server crashing, not the vscode TypeScript extension? It would be helpful to see what happens</p>



<a name="187369534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369534">(Feb 04 2020 at 15:45)</a>:</h4>
<p>VSCode says "Extension host terminated unexpectedly"</p>



<a name="187369667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369667">(Feb 04 2020 at 15:47)</a>:</h4>
<p>Can you show the output of <code>git log --oneline</code> in your local rust-analyzer repo?</p>



<a name="187369673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369673">(Feb 04 2020 at 15:47)</a>:</h4>
<p>Oh wow, found the issue</p>



<a name="187369735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187369735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187369735">(Feb 04 2020 at 15:47)</a>:</h4>
<p>It wasn't actually ra that crashed, but the treesitter extension. I haven't seen it crash in quite some time, and I wonder why it's so crashy when ra is enabled at the same time</p>



<a name="187370510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/obtaining%20backtraces/near/187370510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/obtaining.20backtraces.html#187370510">(Feb 04 2020 at 15:55)</a>:</h4>
<p>Since I was convinced it was ra's fault, I only looked for backtraces in the dev tools, but this time I looked closer and saw that there was a reference to the treesitter extension. So I disabled that and then it stopped crashing...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>